<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="<%= config.basePackage %>mapper.<%= table.className %>Mapper">
    <resultMap id="baseMap" type="<%= config.basePackage %>entity.<%= table.className %>">
        <%= xml.resultMap %>
    </resultMap>

    <sql id="baseColumn">
        <%= xml.baseColumn %>
    </sql>
    <sql id="baseQuery">
        select
        <include refid="baseColumn"/>
        from <%= table.tableName %> tb
    </sql>
    <insert id="insertBatch">
        <%= xml.insertBatch %>
    </insert>
    <update id="updateBatch">
        <%= xml.updateBatch %>
    </update>
    <select id="getPageByLike" resultMap="baseMap">
        <include refid="baseQuery" />
        <where>
        <% columnList.forEach(function (item) { %>
            <% if(config.page === 'pageHelper') {%>
                <%if(item.javaType === 'String'){%>
                    <if test="<%=item.field%> != null and <%=item.field%> != ''">
                        and <%=item.name%> like concat('%', #{<%=item.field%>}, '%')
                <%} else {%>
                    <if test="<%=item.field%> != null">
                        and <%=item.name%> = #{<%=item.field%>}
                <%}%>
            <%}%>
            <% if(config.page === 'mybatisPage') {%>
                <%if(item.javaType === 'String'){%>
                    <if test="dto.<%=item.field%> != null and dto.<%=item.field%> != ''">
                        and <%=item.name%> like concat('%', #{dto.<%=item.field%>}, '%')
                <%} else {%>
                    <if test="dto.<%=item.field%> != null">
                        and <%=item.name%> = #{dto.<%=item.field%>}
                <%}%>
            <%}%>
            </if>
        <% }) %>
        </where>
    </select>
</mapper>
